473,440 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,440 software developers and data experts.

javascript dropdownlist control

sir,

am implementing javascript in my project am begineer to javascript and asp.net

can you please help me for the following queries

here am using one dropdownlist which contains number of persons

whenever i select the number from person dropdownlist it will call the javascript function "AdjustRowsToKidsTable"

that should display the data table which contains number of rows according to the dropdownlist value.

these rows contains firstname(textbox),lastname(textbox),Age(dropdownl ist),and diver(checkbox)

dropdownlist contains 12 numbers
if i choose 10 and above from dropdownlist it will display checkbox corresponding to that row

it works properly but i have problem that not display checkbox pls help me........

now i need your help to implement the above in javascript

Hereby i enclosed the code

Please guide me sir,

Thanking You,

S.Senthil Nathan

function AdjustRowsToKidsTable(form, ddl)
{
var tbl = document.getElementById('tblChildren');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var i = 0
var iteration = lastRow;
var diff = (ddl.options[ddl.selectedIndex].value - (iteration-1));
// alert(ddl.options[ddl.selectedIndex].value, diff);
if ( diff > 0) { // add rows
for (i=iteration;i<=ddl.options[ddl.selectedIndex].value;i++) {
var row = tbl.insertRow(lastRow);
row.bgColor='white';

// First Name
var cellLeft = row.insertCell(0);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txt_fname_child' + iteration;
el.id = 'txt_fname_child' + iteration;
el.maxlength = 45;
el.size = 20;
// el.class = "standard-text";
cellLeft.appendChild(el);

// Last Name
var cellMiddle = row.insertCell(1);
var eln = document.createElement('input');
eln.type = 'text';
eln.name = 'txt_lname_child' + iteration;
eln.id = 'txt_lname_child' + iteration;
el.maxlength = 45;
eln.size = 20;
// eln.class = "standard-text";
cellMiddle.appendChild(eln);


// select cell
var cellRightSel = row.insertCell(2);
var sel = document.createElement('select');
sel.name = 'ddl_Age' + iteration;
sel.options[0] = new Option('1', '1');
sel.options[1] = new Option('2', '2');
sel.options[2] = new Option('3', '3');
sel.options[3] = new Option('4', '4');
sel.options[4] = new Option('5', '5');
sel.options[5] = new Option('6', '6');
sel.options[6] = new Option('7', '7');
sel.options[7] = new Option('8', '8');
sel.options[8] = new Option('9', '9');
sel.options[9] = new Option('10', '10');
sel.options[10] = new Option('11', '11');
sel.options[11] = new Option('12', '12');
cellRightSel.appendChild(sel);

}

// form.txtNoChildren.value = i-1; // set value with numbers
}

if ( diff < 0 ) { // delete rows
for (i=diff;i<0;i++) {
var lastRow = tbl.rows.length;
// alert(lastRow);
if (lastRow > 2) {
tbl.deleteRow(lastRow - 1);
// form.txtNoChildren.value = lastRow-2;
} else {
// form.txtNoChildren.value = lastRow-1;
}

}
}

}
Dec 28 '06 #1
1 8725
r035198x
13,262 8TB
sir,

am implementing javascript in my project am begineer to javascript and asp.net

can you please help me for the following queries

here am using one dropdownlist which contains number of persons

whenever i select the number from person dropdownlist it will call the javascript function "AdjustRowsToKidsTable"

that should display the data table which contains number of rows according to the dropdownlist value.

these rows contains firstname(textbox),lastname(textbox),Age(dropdownl ist),and diver(checkbox)

dropdownlist contains 12 numbers
if i choose 10 and above from dropdownlist it will display checkbox corresponding to that row

it works properly but i have problem that not display checkbox pls help me........

now i need your help to implement the above in javascript

Hereby i enclosed the code

Please guide me sir,

Thanking You,

S.Senthil Nathan

function AdjustRowsToKidsTable(form, ddl)
{
var tbl = document.getElementById('tblChildren');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var i = 0
var iteration = lastRow;
var diff = (ddl.options[ddl.selectedIndex].value - (iteration-1));
// alert(ddl.options[ddl.selectedIndex].value, diff);
if ( diff > 0) { // add rows
for (i=iteration;i<=ddl.options[ddl.selectedIndex].value;i++) {
var row = tbl.insertRow(lastRow);
row.bgColor='white';

// First Name
var cellLeft = row.insertCell(0);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txt_fname_child' + iteration;
el.id = 'txt_fname_child' + iteration;
el.maxlength = 45;
el.size = 20;
// el.class = "standard-text";
cellLeft.appendChild(el);

// Last Name
var cellMiddle = row.insertCell(1);
var eln = document.createElement('input');
eln.type = 'text';
eln.name = 'txt_lname_child' + iteration;
eln.id = 'txt_lname_child' + iteration;
el.maxlength = 45;
eln.size = 20;
// eln.class = "standard-text";
cellMiddle.appendChild(eln);


// select cell
var cellRightSel = row.insertCell(2);
var sel = document.createElement('select');
sel.name = 'ddl_Age' + iteration;
sel.options[0] = new Option('1', '1');
sel.options[1] = new Option('2', '2');
sel.options[2] = new Option('3', '3');
sel.options[3] = new Option('4', '4');
sel.options[4] = new Option('5', '5');
sel.options[5] = new Option('6', '6');
sel.options[6] = new Option('7', '7');
sel.options[7] = new Option('8', '8');
sel.options[8] = new Option('9', '9');
sel.options[9] = new Option('10', '10');
sel.options[10] = new Option('11', '11');
sel.options[11] = new Option('12', '12');
cellRightSel.appendChild(sel);

}

// form.txtNoChildren.value = i-1; // set value with numbers
}

if ( diff < 0 ) { // delete rows
for (i=diff;i<0;i++) {
var lastRow = tbl.rows.length;
// alert(lastRow);
if (lastRow > 2) {
tbl.deleteRow(lastRow - 1);
// form.txtNoChildren.value = lastRow-2;
} else {
// form.txtNoChildren.value = lastRow-1;
}

}
}

}
Where is the code for displaying the checkbox?
Dec 28 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: George Durzi | last post by:
I have a JavaScript called common.js that is referenced by every ASPX in my web application. In common.js, I have a funtion called findText (which I use to help me navigate through drop down lists...
0
by: Phl | last post by:
hi, does any know why my javascript dropdownlist in my user control will only appear if I have my code as follows: // create an instance of the user control Control UCAdminDDMenu =...
0
by: Caesar Augustus | last post by:
I'm having a problem with two different javascript controls in my app. The first chuck of javascript that I pasted into my app is the client-side calendar control popup which works fine when first...
6
by: Oscar | last post by:
I want to add items to a dropdownlist control within a Javascript eventhandler. This is what I code : var dd = document.getElementById("DropDownList1"); dd.Items.Add("1990");...
7
by: =?Utf-8?B?Qw==?= | last post by:
I have a dropdown list as below. I add an onchnage attribute in my codebehind to call some Javascript. I want to get the selected text from my dropdown. What am I doing wrong below? ...
3
by: Radu | last post by:
Hi. I have the following problem - I need to build a user-control in asp.net (an ascx) to somehow allow the users to search by first name or last name among a big (~10.000 records) email addresses...
3
by: John Kotuby | last post by:
Hi all... I am trying to do a simple thing and maybe am missing something elementary. I have created a Javascript function at the top of a page which is meant to enable editing of an HTML input...
0
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, imagine this for a moment if you will: i have a row in a gridview that when it is in edit mode there is a column that contains a dropdownlist and 2nd column that contains a user control....
2
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.